An Automatic Partial Evaluator for Full Prolog

نویسنده

  • Dan Sahlin
چکیده

A partial evaluator for Prolog takes a program and a query and returns a program specialized for all instances of that query. The intention is that the generated program will execute more efficiently than the original one for those instances. This thesis presents “Mixtus”, an automatic partial evaluator for full Prolog, i.e. including non-logical features such as cut, assert, var, write etc. Mixtus does not need any annotations to guide it in its process, but will automatically generate a program given only an input program and a query. A definition of partial evaluation based on the procedural semantics rather than declarative semantics is presented. A program transformed by Mixtus will behave identically as the original one, including side-effects and the order of the solutions returned. The three basic program transformations “unfolding”, “folding” and “definition” are adapted to full Prolog. The most important transformation is “unfolding” which is used by all partial evaluators to eliminate run-time procedure calls. The “folding” and “definition” transformations generate new recursive predicates specialized for the query. A loop prevention mechanism specifically tailored for partial evaluation together with a mechanism for “generalized restart”, will guarantee the termination of the partial evaluation for all programs. Special attention is given to built-in predicates, the cut in particular. To facilitate the execution and removal of cuts during partial evaluation a module for determinacy analysis is used. As negation in Prolog is based on the cut, it will also be treated correctly. Some of the other predicates that are given extra care are dif/2, findall/3 and bagof/3. Many program transformations possible in a logic programming framework will not work correctly for full Prolog. Built-in and generated predicates are therefore classified according to their declarative “purity” so that the “impure” predicates will not hinder the optimization process unnecessarily. It is a non-trivial task to implement a partial evaluator, so the basic features of the implementation of Mixtus are also presented. A number of sample programs are partially evaluated, and the effect is discussed.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Logimix: A Self-Applicable Partial Evaluator for Prolog

We present a self-applicable partial evaluator for a large subset of full Prolog. The partial evaluator, called Logimix, is the result of applying our experience from partial evaluation of functional languages to Prolog. Great care is taken to preserve the operational semantics of the partially evaluated programs, including the effects of non-logical predicates and side effects. At the same tim...

متن کامل

LIX: an Effective Self-applicable Partial Evaluator for Prolog

This paper presents a self-applicable partial evaluator for a considerable subset of full Prolog. The partial evaluator is shown to achieve non-trivial specialisation and be effectively self-applied. The attempts to self-apply partial evaluators for logic programs have, of yet, not been all that successful. Compared to earlier attempts, our lix system is practically usable in terms of efficienc...

متن کامل

Towards Just-In-Time Partial Evaluation of Prolog

We introduce a just-in-time specializer for Prolog. Just-intime specialization attempts to unify of the concepts and benefits of partial evaluation (PE) and just-in-time (JIT) compilation. It is a variant of PE that occurs purely at runtime, which lazily generates residual code and is constantly driven by runtime feedback. Our prototype is an on-line just-in-time partial evaluator. A major focu...

متن کامل

Partial Evaluation of Call - by - value - calculus with Side - e ects

We present a framework of an online partial evaluator for a call-by-value -calculus with destructive updates of data structures. To our knowledge, this is the rst partial evaluator that can deal with full side-e ects as well as pointer equality in higher-order languages. Our partial evaluator uses a side-e ect analysis for handling assignment operations and then performs an online specializatio...

متن کامل

Efficient Local Unfolding with Ancestor Stacks for Full Prolog

Abs t r ac t . The integration of powerful partial evaluation methods into practical compilers for logic programs is still far from reality. This is related both to 1) efficiency issues and to 2) the complications of dealing with practical programs. Regarding efnciency, the most successful unfolding rules used nowadays are based on structural orders applied over (covering) ancestors, i.e., a su...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1991